package com.example.animator;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.ImageView;

import static android.view.animation.Animation.INFINITE;

public class MainActivity extends AppCompatActivity {

    private boolean flag = true;// 标记位，轮换展示两种自定义动画
//    private ImageView iv01;
    private ImageView iv02;
//    private Button btnFz;
    private Button btn3d;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        iv01 = findViewById(R.id.iv_ani);
        iv02 = findViewById(R.id.iv_ani2);
//        btnFz = findViewById(R.id.btn_fz);
//        btn3d = findViewById(R.id.btn_3d);
//        btnFz.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                TVCloseAni tvAni = new TVCloseAni();
//                tvAni.setRepeatCount(INFINITE);
//                tvAni.setRepeatCount(INFINITE);
//                iv01.startAnimation(tvAni);
//            }
//        });


        Custom3DAni custom3DAni = new Custom3DAni();
        custom3DAni.setRepeatCount(INFINITE);
        custom3DAni.setRepeatMode(Animation.RESTART);
//                custom3DAni.setRotateY(-180);
        custom3DAni.setRotateY(-180);
        iv02.startAnimation(custom3DAni);

//        btn3d.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Custom3DAni custom3DAni = new Custom3DAni();
//                custom3DAni.setRepeatCount(INFINITE);
//                custom3DAni.setRepeatMode(Animation.RESTART);
////                custom3DAni.setRotateY(-180);
//                custom3DAni.setRotateY(-180);
//                iv02.startAnimation(custom3DAni);
//            }
//        });
    }

//    /**
//     * 设置按钮点击事件
//     */
//    public void startCustomAni(View view) {
//        if (flag) {
//            TVCloseAni tvAni = new TVCloseAni();
//            view.startAnimation(tvAni);
//            // 重置标记位
//            flag = false;
//        } else {
//            Custom3DAni customAni = new Custom3DAni();
//            customAni.setRotateY(30);
//            view.startAnimation(customAni);
//            // 重置标记位
//            flag = true;
//        }
//    }

}
